package com.mrd.gtimpframe.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.mrd.util.StringUtils;

public class CargoDeclaRecord implements Serializable {
    private String id;

    /**
     * 报关单ID
     */
    private String did;
    /**
     * 业务编码
     */
    private String businessNo;
    /**
     * 进出口标识
     */
    private String ieFlag;
    /**
     * 直航转关标识
     */
    private String trnFlag;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 公司ID
     */
    private String companyId;
    /**
     * 报关状态 广州单一窗口
     * 0 = '初始化'
     * -1 = '上传失败'
     * 1 = '上载中'
     * 2 = '上载成功'
     * 3 = '上载失败'
     * 4 = '暂存'
     * 5 = '申报失败'
     * 6 = '申报中'
     * 8 = '申报成功'
     * 12 = '担保放行'
     * 16 = '报关单审结'
     * 18 = '需交税费'
     * 20 = '海关删单'
     * 21 = '报关单重审'
     * 22 = '结关'
     * 23 = '查验通知'
     * 25 = '报关单放行'
     * 27 = '进港回执'
     * 9 = '海关已接收'
     * 10 = '不被受理'
     * 11 = '需手工申报'
     * 13 = '退回修改'
     * 14 = '放行交单'
     * 28 = '通关无纸化放行'
     * 29 = '通关无纸化审结'
     * 30 = '修撤单需要补传/重传'
     * ------------------------------------
     * ------------------------------------
     * 报关状态 国版单一窗口
     * 0 = '上传中'
     * TS = '暂存'
     * TF = '上传失败'
     * L 海关入库回执
     * E 海关退单/不受理回执
     * G 海关接单交单回执
     * F 海关放行交单回执
     * W 海关无纸验放通知（审结）
     * I 海关无纸放行通知（放行）
     * C 海关无纸验放查验通知书（放行）
     * B 海关担保验放
     * P 海关已放行
     * P 海关已放行
     * R 海关已结关回执
     * H 海关挂起，需手工申报
     * M 海关重新审核通过
     * A 海关放行前删除或者异常处理（手工申报通知）
     * D 海关放行后删除
     * X 海关准予进港回执（上海洋山保税港区专用）
     * H（H883） 海关手工申报回执
     * Z（H883） 海关退回修改通知
     * T（H883） 海关税费通知
     * J 通关无纸化审结回执（审结回执一种）
     * N 补传随附单证电子数据
     * K 通关无纸化担保放行
     * 7 申报成功
     * 8 申报失败
     */
    private String status;
    /**
     * 报关单号
     */
    private String entryNo;
    /**
     * 关检号
     */
    private String invNo;
    /**
     * 关检密码
     */
    private String invPwd;
    /**
     * 上传方式
     * GZ_PORT_HTTPS 广州单一窗口接口对接
     * COM_PORT_FTP 国家单一窗口客户端对接，ftp实现。
     */
    private String uploadWay;

    /**
     * 数据状态 0:正常，1:无效
     */
    private String state;

    /**
     * 错误提示
     */
    private String failInfo;
    private static final long serialVersionUID = 1L;

    public CargoDeclaRecord(String id, String did, String businessNo, String ieFlag, String trnFlag, Date createTime, Date updateTime, String companyId, String status, String entryNo, String invNo, String invPwd, String uploadWay) {
        this.id = id;
        this.did = did;
        this.businessNo = businessNo;
        this.ieFlag = ieFlag;
        this.trnFlag = trnFlag;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.companyId = companyId;
        this.status = status;
        this.entryNo = entryNo;
        this.invNo = invNo;
        this.invPwd = invPwd;
        this.uploadWay = uploadWay;
    }

    public CargoDeclaRecord() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getDid() {
        return did;
    }

    public void setDid(String did) {
        this.did = did == null ? null : did.trim();
    }

    public String getBusinessNo() {
        return businessNo;
    }

    public void setBusinessNo(String businessNo) {
        this.businessNo = businessNo == null ? null : businessNo.trim();
    }

    public String getIeFlag() {
        return ieFlag;
    }

    public void setIeFlag(String ieFlag) {
        this.ieFlag = ieFlag == null ? null : ieFlag.trim();
    }

    public String getTrnFlag() {
        return trnFlag;
    }

    public void setTrnFlag(String trnFlag) {
        this.trnFlag = trnFlag == null ? null : trnFlag.trim();
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId == null ? null : companyId.trim();
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status == null ? null : status.trim();
    }

    public String getEntryNo() {
        return entryNo;
    }

    public void setEntryNo(String entryNo) {
        this.entryNo = entryNo == null ? null : entryNo.trim();
    }

    public String getInvNo() {
        return invNo;
    }

    public void setInvNo(String invNo) {
        this.invNo = invNo == null ? null : invNo.trim();
    }

    public String getInvPwd() {
        return invPwd;
    }

    public void setInvPwd(String invPwd) {
        this.invPwd = invPwd == null ? null : invPwd.trim();
    }

    public String getUploadWay() {
        return uploadWay;
    }

    public void setUploadWay(String uploadWay) {
        this.uploadWay = uploadWay == null ? null : uploadWay.trim();
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getFailInfo() {
        return failInfo;
    }

    public void setFailInfo(String failInfo) {
        this.failInfo = failInfo;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CargoDeclaRecord other = (CargoDeclaRecord) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getDid() == null ? other.getDid() == null : this.getDid().equals(other.getDid())) && (this.getBusinessNo() == null ? other.getBusinessNo() == null : this.getBusinessNo().equals(other.getBusinessNo())) && (this.getIeFlag() == null ? other.getIeFlag() == null : this.getIeFlag().equals(other.getIeFlag())) && (this.getTrnFlag() == null ? other.getTrnFlag() == null : this.getTrnFlag().equals(other.getTrnFlag())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getEntryNo() == null ? other.getEntryNo() == null : this.getEntryNo().equals(other.getEntryNo())) && (this.getInvNo() == null ? other.getInvNo() == null : this.getInvNo().equals(other.getInvNo())) && (this.getInvPwd() == null ? other.getInvPwd() == null : this.getInvPwd().equals(other.getInvPwd())) && (this.getUploadWay() == null ? other.getUploadWay() == null : this.getUploadWay().equals(other.getUploadWay())) && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState())) && (this.getFailInfo() == null ? other.getFailInfo() == null : this.getFailInfo().equals(other.getFailInfo()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getDid() == null) ? 0 : getDid().hashCode());
        result = prime * result + ((getBusinessNo() == null) ? 0 : getBusinessNo().hashCode());
        result = prime * result + ((getIeFlag() == null) ? 0 : getIeFlag().hashCode());
        result = prime * result + ((getTrnFlag() == null) ? 0 : getTrnFlag().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getEntryNo() == null) ? 0 : getEntryNo().hashCode());
        result = prime * result + ((getInvNo() == null) ? 0 : getInvNo().hashCode());
        result = prime * result + ((getInvPwd() == null) ? 0 : getInvPwd().hashCode());
        result = prime * result + ((getUploadWay() == null) ? 0 : getUploadWay().hashCode());
        result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
        result = prime * result + ((getFailInfo() == null) ? 0 : getFailInfo().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", did=").append(did);
        sb.append(", businessNo=").append(businessNo);
        sb.append(", ieFlag=").append(ieFlag);
        sb.append(", trnFlag=").append(trnFlag);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", companyId=").append(companyId);
        sb.append(", status=").append(status);
        sb.append(", entryNo=").append(entryNo);
        sb.append(", invNo=").append(invNo);
        sb.append(", invPwd=").append(invPwd);
        sb.append(", uploadWay=").append(uploadWay);
        sb.append(", state=").append(state);
        sb.append(", failInfo=").append(failInfo);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    public String getStatusLab() {
        String lab = "";
        if (StringUtils.isEmpty(this.status)) {
            return lab;
        }
        Map<String, String> mapping = new HashMap<>();
        if (ComDeclaWay.WayCodeEnum.GZ_PORT_HTTPS.toString().equals(this.uploadWay)) {
            if ("-1".equals(this.status)) {
                return "";
            }
            mapping.put("-1", "上传电子口岸失败");
            mapping.put("0", "正在上传");
            mapping.put("1", "上载中");
            mapping.put("2", "上载成功");
            mapping.put("3", "上载失败");
            mapping.put("4", "暂存");
            mapping.put("5", "申报失败");
            mapping.put("6", "申报中");
            mapping.put("7", "");
            mapping.put("8", "申报成功");
            mapping.put("9", "海关已接收");
            mapping.put("10", "不被受理");
            mapping.put("11", "需手工申报");
            mapping.put("12", "担保放行");
            mapping.put("13", "退回修改");
            mapping.put("14", "放行交单");
            mapping.put("15", "");
            mapping.put("16", "报关单审结");
            mapping.put("17", "");
            mapping.put("18", "需交税费");
            mapping.put("19", "");
            mapping.put("20", "海关删单");
            mapping.put("21", "报关单重审");
            mapping.put("22", "结关");
            mapping.put("23", "查验通知");
            mapping.put("24", "");
            mapping.put("25", "报关单放行");
            mapping.put("26", "");
            mapping.put("27", "进港回执");
            mapping.put("28", "通关无纸化放行");
            mapping.put("29", "通关无纸化审结");
            mapping.put("30", "修撤单需要补传/重传");
        } else if (ComDeclaWay.WayCodeEnum.COM_PORT_FTP.toString().equals(this.uploadWay)) {
            mapping.put("TU", "正在上传");
            mapping.put("TM", "提交");
            mapping.put("TUS", "上传完成");
            mapping.put("TS", "暂存");
            mapping.put("TF", "上传失败");
            mapping.put("TUF", "暂存失败");
            mapping.put("L", "海关入库");
            mapping.put("E", "海关退单/不受理");
            mapping.put("G", "海关接单交单");
            mapping.put("F", "海关放行交单");
            mapping.put("W", "海关无纸验放（审结）");
            mapping.put("I", "海关无纸放行（放行）");
            mapping.put("C", "海关无纸验放查验通知书（放行）");
            mapping.put("B", "海关担保验放");
            mapping.put("P", "海关已放行");
            mapping.put("R", "海关已结关");
            mapping.put("H", "海关挂起，需手工申报");
            mapping.put("M", "海关重新审核通过");
            mapping.put("A", "海关放行前删除或者异常处理（手工申报通知）");
            mapping.put("D", "海关放行后删除");
            mapping.put("X", "海关准予进港");
            mapping.put("H", "海关手工申报");
            mapping.put("Z", "海关退回修改");
            mapping.put("T", "海关税费");
            mapping.put("J", "通关无纸化审结");
            mapping.put("N", "补传随附单证电子数据");
            mapping.put("K", "通关无纸化担保放行");
            mapping.put("7", "申报成功");
            mapping.put("8", "申报失败");
        }
        lab = mapping.get(this.status);

        return lab;
    }
}
